package edu.ucdavis.gwt.gis.client.toolbar.button;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.ui.Image;

import edu.ucdavis.gwt.gis.client.DataManager;
import edu.ucdavis.gwt.gis.client.draw.DrawControl;
import edu.ucdavis.gwt.gis.client.resources.GadgetResources;
import edu.ucdavis.gwt.gis.client.toolbar.Toolbar;

public class AddFeaturesButton extends ToolbarItem {
	
	public AddFeaturesButton(){
		DataManager.INSTANCE.getMap().addControl(DrawControl.INSTANCE);
	}

	@Override
	public Image getIcon() {
		return new Image(GadgetResources.INSTANCE.draw());
	}

	@Override
	public void onAdd(Toolbar toolbar) {}

	@Override
	public void onClick(ClickEvent event) {
		DrawControl.INSTANCE.enable(!DrawControl.INSTANCE.isEnabled());
	}

	@Override
	public String getText() {
		return "Draw Features";
	}

}
